package com.by.common.controller;

import com.by.common.bean.ResultBean;
import com.by.common.exception.ValidateException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


/**
 * @author 江俊俊
 * @version 1.0
 * @description
 * @date 2025/2/14 14:28
 * @since JDK1.8
 */
@RestControllerAdvice
public class GlobalExceptionController extends BaseController{

    /**
     * 捕获后端验证异常
     * @param e
     * @return
     */
    @ExceptionHandler(ValidateException.class)
    public ResultBean handler(ValidateException e){
        return fail("验证失败",e.getErrorMap());
    }
}
